package com.mentaleye.biz.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mentaleye.bean.DeptRelationBean;
import com.mentaleye.biz.DeptRelationBiz;
import com.mentaleye.service.DeptRelationService;
import com.mentaleye.util.CommonResult;

@Service
public class DeptRelationBizImpl implements DeptRelationBiz{

	@Autowired private DeptRelationService deptRelationService;
	
	private static Logger logger = Logger.getLogger(DeptRelationBizImpl.class);
	
	@Override
	public CommonResult addDeptRelation(DeptRelationBean bean){
		boolean success = false;
		try {
			success = deptRelationService.addDeptRelation(bean);
		} catch (Exception e) {
			logger.error("机构添加教师异常", e);
		}
		return new CommonResult(success);
	}
	
	@Override
	public CommonResult addDeptRelationList(List<DeptRelationBean> deptRelationBeanList){
		boolean success = false;
		try {
			success = deptRelationService.addDeptRelationList(deptRelationBeanList);
		} catch (Exception e) {
			logger.error("机构批量添加教师异常", e);
		}
		return new CommonResult(success);
	}
	
	@Override
	public CommonResult removeDeptRelationOne(int deptId,int teacherId){
		boolean success = false;
		try {
			success = deptRelationService.removeDeptRelationOne(deptId, teacherId);
		} catch (Exception e) {
			logger.error("删除部门教师异常", e);
		}
		return new CommonResult(success);
	}
	
	@Override
	public CommonResult removeDeptRelationList(Integer deptId,List<Integer> teacherids){
		boolean success = false;
		try {
			success = deptRelationService.removeDeptRelationList(deptId, teacherids);
		} catch (Exception e) {
			logger.error("批量删除部门教师失败", e);
		}
		return new CommonResult(success);
	}
	
	@Override
	public DeptRelationBean queryDeptRelationOne(int deptId,int teacherId){
		return deptRelationService.queryDeptRelationOne(deptId, teacherId);
	}
	
	@Override
	public List<DeptRelationBean> queryDeptRelationList(DeptRelationBean bean){
		return deptRelationService.queryDeptRelationList(bean);
	}
}
